#include "Process.h"

Process::Process(int* args, pid schedulerId, int initialPriority, int cpuTimeNeeded) {
	c1 = args[0];
	c2 = args[1];
	b1 = args[2];
	b2 = args[3];
	x0 = args[4];
	y0 = args[5];
	w = args[6];
	schedulerPid = schedulerId;
	totalCpuTimeNeeded = cpuTimeNeeded;
	cpuTimeUsed = 0;
}

Process::~Process() {

}

void Process::sendClockTick() {
	kill(schedulerPid, SIGUSR1);
}
int Process::computeBlockTimeNeeded() //part 2
{

}
void catchSIGUSR1(int num) {
	sigset_t signalset;
	signal(SIGUSR1, catchSIGUSR1);
	sigfillset(&signalset);
	sigdelset(&signalset, SIGUSR2);
	sigsuspend(&signalset);
}
void Process::updateStatistics() {
	
}
void Process::run() {
	while (cpuTimeUsed<totalCpuTimeNeeded)
	{
		cpuTimeUsed++;
		sendClockTick();
	}
}